home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Memory deallocation and linked lists
- Date: 17 Apr 1996 08:47:16 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4l33q4INN8tt@keats.ugrad.cs.ubc.ca>
- References: <4l1hpk$hk5@alice.walrus.com> <4l2tqk$pt1@gcsin3.geccs.gecm.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4l2tqk$pt1@gcsin3.geccs.gecm.com>,
- Richard Gilchrist <richard.gilchrist@gecm.com> wrote:
- >warrenj@walrus.com (Warren Johnson) wrote:
- >>Greetings!
- >>Let us suppose I have a singularly linked list. If i free up the first
- >>node, will all of the rest of the nodes be freed up as well? Free
- >>meaning, using the borland command free(). Do I have to free up each node
- >>seperately? Something I've never actually known >:). Thanks in advance.
-
- >Warren,
- >
- >I can't remember what the borland command free() does exactly, but the UNIX c
- >command free() requires you to must traverse the list and free each element of the
- >list, and I don't think that the borland command will be much different from the
- >UNIX free command.
-
- free is a standard defined library _function_, not a Borland or UNIX
- ``command''. It is defined by the C language standard to have consistent
- semantics across all implementations.
-
- malloc() and free() have no concept of the data structure that you are building
- using the allocated units. They have no idea that the list node you are freeing
- contains pointers to other nodes that you also want to free, or that other
- nodes point to it. As far as these allocator functions are concerned, the
- contents of the node are just a bunch of bytes.
- --
- I'm not really a jerk, but I play one on Usenet.
-